<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/7/18
 * Time: 16:10
 */

namespace app\models;


use shmilyzxt\queue\base\JobHandler;

class QueueTest extends JobHandler
{
    public function handle($job,$data)
    {
        if($job->getAttempts() > 3){
            $this->failed($job);
        }

        $payload = $job->getPayload();

        //$payload即任务的数据，你拿到任务数据后就可以执行发邮件了
        //TODO 发邮件
        file_put_contents($payload->file, file_get_contents($payload->url));
    }

    public function failed($job,$data)
    {
        die("发了3次都失败了，算了");
    }
}